package Test29;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

//LocalDateTime类的使用

public class Test13 {
    public static void main(String[] args) {
        //获取当前时间的年月日时分秒
        LocalDateTime nowDateTime = LocalDateTime.now();

        System.out.println("今天现在的时间是" + nowDateTime);
        System.out.println(nowDateTime.getYear());//年
        System.out.println(nowDateTime.getMonthValue());//月
        System.out.println(nowDateTime.getDayOfMonth());//日
        System.out.println(nowDateTime.getHour());//时
        System.out.println(nowDateTime.getMinute());//分
        System.out.println(nowDateTime.getSecond());//秒
        System.out.println(nowDateTime.getNano());//纳秒

        //日：当年的第几天
        System.out.println("dayOfYear：" + nowDateTime.getDayOfYear());

        //星期
        System.out.println(nowDateTime.getDayOfWeek());
        System.out.println(nowDateTime.getDayOfWeek().getValue());

        //月份
        System.out.println(nowDateTime.getMonth());
        System.out.println(nowDateTime.getMonth().getValue());


        LocalDate ld = nowDateTime.toLocalDate();
        System.out.println(ld);

        LocalTime lt = nowDateTime.toLocalTime();
        System.out.println(lt);
        System.out.println(lt.getHour());
        System.out.println(lt.getMinute());
        System.out.println(lt.getSecond());
        System.out.println(lt.getNano());
    }
}
